import App from "./App.vue";
import router from "./router";
import store from "./store";
import { Toast, Lazyload } from "vant"; // 全局公共taost，使用this.$toast方法
import directives from './directives/index'
import i18n from './i18n'
import './assets/css/public.less'
import './registerServiceWorker'
// 注册时可以配置额外的选项
Vue.use(Lazyload, {
  lazyComponent: false,
});
// 参考https://vant-contrib.gitee.io/vant/#/zh-CN/lazyload
Vue.prototype.$toast = Toast;
Vue.config.productionTip = false;

if (window) window.$t = (key, value) => i18n.t(key, value);

// 公共directives, 可单独引入，不全局处理
Vue.use(directives)

Vue.config.errorHandler = function (err, vm, info) {
  if(process.env.NODE_ENV === 'development') {
      console.log('err', err)
      console.log('vm', vm)
      console.log('info', info)
  }
  // handle error
  // `info` 是 Vue 特定的错误信息，比如错误所在的生命周期钩子
}
// Vue.config.performance = true

new Vue({
  router,
  store,
  i18n,
  render: (h) => h(App),
  mounted() {
    document.dispatchEvent(new Event('render-event'))
  },
}).$mount("#app");
